﻿@model Yoze.Web.Models.MyFriendViewModel
@{
    ViewBag.Title = "My Friends";
}

<h2>My Friends</h2>


<div class="panel panel-default">
    <div class="panel-heading">Invite a Friend</div>
    <div class="panel-body">
        @using (Html.BeginForm("Invite", "MyFriend", FormMethod.Post, new { @class = "form-inline", role = "form" }))
        {
            @Html.AntiForgeryToken()
            @Html.ValidationSummary("", new { @class = "text-danger" })

            <div class="form-group">
                <span class="control-label">Select a user to invite as my friend: </span>
                @Html.DropDownListFor(m => m.SelectedUserId, Model.UserNames, new { @class = "form-control" })
            </div>
            <div class="form-group">
                @Html.TextBoxFor(m => m.InvitationLetter, new { @class = "form-control" })
            </div>
            <button type="submit" class="btn btn-primary">Send Invitation</button>
        }
    </div>
</div>

<div class="panel panel-default">
    <div class="panel-heading">My Sent Invitations</div>
    <div class="panel-body">
        <div class="table-responsive">
            <table class="table table-striped table-hover table-responsive">
                <thead>
                    <tr>
                        <th>
                            To User
                        </th>
                        <th>
                            Sent Date
                        </th>
                        <th>
                            Status
                        </th>
                        <th>
                            Complete Date
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var m in Model.SentInvitations)
                    {
                        <tr>
                            <td>@m.UserDisplayName</td>
                            <td>@m.SentDate.ToShortDateString()</td>
                            <td>@m.Status</td>
                            <td>
                                @if(m.IsCompleted)
                                {
                                    <span>@m.CompleteDate.Value.ToShortDateString()</span>
                                }
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="panel panel-default">
    <div class="panel-heading">My Received Invitations</div>
    <div class="panel-body">
        <div class="table-responsive">
            <table class="table table-striped table-hover table-responsive">
                <thead>
                    <tr>
                        <th>
                            From User
                        </th>
                        <th>
                            Sent Date
                        </th>
                        <th>
                            Status
                        </th>
                        <th>
                            Complete Date
                        </th>
                        <th>
                            Approve
                        </th>
                        <th>
                            Reject
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var m in Model.ReceivedInvitations)
                    {
                        <tr>
                            <td>@m.UserDisplayName</td>
                            <td>@m.SentDate.ToShortDateString()</td>
                            <td>@m.Status</td>
                            <td>
                                @if (m.IsCompleted)
                                {
                                    <span>@m.CompleteDate.Value.ToShortDateString()</span>
                                }
                            </td>
                            <td>
                                
                                @if (!m.IsCompleted)
                                {
                                    @Html.ActionLink("Accept", "Accept", new { InvitationId = m.InvitationId })
                                }
                            </td>
                            <td>
                                @if (!m.IsCompleted)
                                {
                                    @Html.ActionLink("Reject", "Reject", new { InvitationId = m.InvitationId })
                                }
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

